const path = require('path')
const { merge } = require('webpack-merge');
const webpackcommon = require('./webpack.common.js')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const copyWebpackPlugin = require('copy-webpack-plugin')
const webpack = require('webpack')

module.exports = merge(webpackcommon, {
  mode: 'production',
  entry: './src/main.js',
  output: {
    path: path.resolve(__dirname, 'dist')
  },
  resolve: {
    alias: {
      'vue$': 'vue/dist/vue.esm.js',
      'less-loader': 'less-loader'
    }
  },
  devtool: false,
  plugins: [
    new webpack.DefinePlugin({
      BASE_URL: JSON.stringify('./public/')
    }),
    new CleanWebpackPlugin(),
    new copyWebpackPlugin({
      patterns: [
        {
          from: './public/*.ico',
          to: path.resolve(__dirname, 'dist')
        }
      ]
    })
  ]
})
